from selenium import webdriver # 导入依赖
driver = webdriver.Chrome() #实例化驱动
driver.get("http://www.baidu.com/") # 打开指定网址
driver.maximize_window() # 全屏
# 定位搜索框
# //*[@id='kw']
# 导入操作模块
from selenium.webdriver.common.by import By
# 根据一组中的id定位xpath
# driver.find_element(By.XPATH,"//*[@id='kw']").send_keys("王长帅1号")
# 根据一组中的name定位xpath
# driver.find_element(By.XPATH,"//*[@name='wd']").send_keys("王长帅1号")
# 根据一组中的class定位xpath
# driver.find_element(By.XPATH,"//*[@class='s_ipt']").send_keys("王长帅2号")
# 根据两个元素定位
# driver.find_element(By.XPATH,"//*[@id='kw' and @class='s_ipt']").send_keys("王长帅3号")
# 根据文本定位：地图
driver.find_element(By.XPATH,"//*[text()='地图']").click()
# text() 后面跟的是文本信息为：地图
text1 = driver.find_element(By.LINK_TEXT,'地图').text
print(text1)

















